#include <iostream>
#include <string>
#include <cstdlib>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>

using namespace std;

void Usage(string proc)
{
    cout << "Usage:\n\t" << proc << " signum pid\n\n";
}

void myhandler(int signo)
{
    cout << "process get a signal: " << signo <<endl;
    // exit(1);
}

// mykill signum pid
int main(int argc, char *argv[])
{
    // signal(2, myhandler);
    
    signal(SIGABRT, myhandler);
    int cnt = 0;
    while (true)
    {
        cout << "I am a process, pid: " << getpid() << endl;
        sleep(1);
        cnt++;
        if(cnt % 2 == 0) 
        {
            //kill(getpid(), 2);
            //raise(2);
            //abort();
            // kill(getpid(), 6);
        }
    }
}